/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package com.playground.core.repository.memory;

import com.playground.core.entity.Invitation;
import com.playground.core.entity.Player;
import com.playground.core.repository.InvitationRepository;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import org.springframework.stereotype.Service;

/**
 *
 * @author Tiago Peres
 */
@Service
public class InvitationRepositoryImpl implements InvitationRepository{
    private static HashMap<Player, Invitation> invitations = new HashMap<Player, Invitation>();
    
    public Invitation save(Invitation invitation) {
        invitations.put(invitation.getHost(), invitation);
        return invitation;
    }

    public Invitation getInvitationByHost(Player player) {
        return invitations.get(player);
    }

    public void delete(Invitation invitation) {
        invitations.remove(invitation.getHost());
    }

    public List<Invitation> findAll() {
        return new ArrayList(invitations.values());
    }

    public void deleteAll() {
        invitations = new HashMap<Player, Invitation>();
    }
    
}
